package crmdna.client.member;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;

import crmdna.client.contactdetail.ContactDetail.ContactDetailProp;
import crmdna.client.member.MemberCore.MemberProp;

@Entity @Cache
public class MemberEntity {
	@Id long memberId;
	
	@Index String email;
			
	String firstName;
	String lastName;
	
	String homeAddress;
	String officeAddress;
	String homePhone;
	String officePhone;
	String mobilePhone;	
		
	@Index Set<Long> groupIds = new HashSet<>();
			
	@Index Set<String> qsTags;
	@Index Set<Long> programIds = new HashSet<>();
	 
	Map<String, String> customFields;
	
	Set<Long> interactionIds = new HashSet<>();
	
	//dependents
	@Index String name;	
	@Index String nameFirstChar;
	@Index Set<Long> programTypeIds = new HashSet<>();
	@Index Set<Long> practiceIds = new HashSet<>(); 
	@Index Set<String> phoneNumbers = new HashSet<>();
	
	public MemberProp toProp() {
		MemberProp prop = new MemberProp();	
		prop.memberId = memberId;
		prop.contact = new ContactDetailProp();
		prop.contact.email = email;
		prop.contact.firstName = firstName;
		prop.contact.lastName = lastName;
		prop.contact.homeAddress = homeAddress;
		prop.contact.officeAddress = officeAddress;
		prop.contact.homePhone = homePhone;
		prop.contact.officePhone = officePhone;
		prop.contact.mobilePhone = mobilePhone;
		
		prop.name = name;
		//prop.qsTags = qsTags;
		prop.groupIds = groupIds;
		
		prop.interactionIds = interactionIds;
		
		prop.programIds = programIds;
		prop.programTypeIds = programTypeIds;
		prop.practiceIds = practiceIds;
				
		return prop;
	}
}
